package com.jerome.election.server;

/**
 * HttpMethod enumeration
 * @author jerome
 * @date 2023/7/28
 */
public enum PaxosMethodEnum {

    //PREPARE 请求,
    PREPARE("PREPARE"),
    //ACCEPT 请求
    ACCEPT("ACCEPT"),
    //LEARN 请求
    LEARN("LEARN"),
    // 心跳 保持socket 长连接
    PINGPONG("PINGPONG"),
    // leader 维持统治
    LEADER("LEADER"),
    /*******下面用于数据同步 如果只用选举无需使用*******/
    //同步
    SYNC("SYNC"),
    //增量同步
    INCREMENT_SYNC("INCREMENT_SYNC"),
    ;

    public static PaxosMethodEnum getByCode(String code){
        for (PaxosMethodEnum value : PaxosMethodEnum.values()) {
            if (code.equals(value.code)){
                return value;
            }
        }
        return PINGPONG;
    }

    private String code;

    PaxosMethodEnum(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
    
}
